From: Marco Trevisan (TreviƱo) Date: Mon, 20 May 2019 21:25:14 +0000 (+0200) Subject: lookingGlass: Use resultsArea to keep track of results X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~781^2^2~524 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=4dea1f801ae130b2a5c80537c4e05189dab0f6df;p=gnome-shell.git lookingGlass: Use resultsArea to keep track of results Now that results are actors we can just use their container to keep track of them https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559 --- diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 85e8874b1..38e45edb4 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -793,7 +793,6 @@ class LookingGlass extends St.BoxLayout { this._it = null; this._offset = 0; - this._results = []; // Sort of magic, but...eh. this._maxItems = 150; @@ -937,17 +936,14 @@ class LookingGlass extends St.BoxLayout { } _pushResult(command, obj) { - let index = this._results.length + this._offset; + let index = this._resultsArea.get_n_children() + this._offset; let result = new Result(this, CHEVRON + command, obj, index); - this._results.push(result); this._resultsArea.add(result); if (obj instanceof Clutter.Actor) this.setBorderPaintTarget(obj); - let children = this._resultsArea.get_children(); - if (children.length > this._maxItems) { - this._results.shift(); - children[0].destroy(); + if (this._resultsArea.get_n_children() > this._maxItems) { + this._resultsArea.get_first_child().destroy(); this._offset++; } this._it = obj; @@ -1034,7 +1030,7 @@ class LookingGlass extends St.BoxLayout { getResult(idx) { try { - return this._results[idx - this._offset].o; + return this._resultsArea.get_child_at_index(idx - this._offset).o; } catch (e) { throw new Error(`Unknown result at index ${idx}`); }